// TPFactoryView.cpp : implementation of the CTPFactoryView class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"

#include "TPFactoryView.h"

#include "TPTools.h"

BOOL CTPFactoryView::PreTranslateMessage(MSG* pMsg)
{
	return CWindow::IsDialogMessage(pMsg);
}

LRESULT CTPFactoryView::OnBnClickedBrowserConfig(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(TRUE, _T("xml"));

	if ( IDOK == dlg.DoModal() )
	{
		m_strConfig = dlg.m_ofn.lpstrFile;
		DoDataExchange(FALSE);
	}

	return 0;
}

LRESULT CTPFactoryView::OnBnClickedBrowserMp3(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(TRUE, _T("mp3"));

	if ( IDOK == dlg.DoModal() )
	{
		m_strMP3 = dlg.m_ofn.lpstrFile;
		DoDataExchange(FALSE);
	}

	return 0;
}

LRESULT CTPFactoryView::OnBnClickedBrowserOut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(FALSE, _T("tpm"));

	if ( IDOK == dlg.DoModal() )
	{
		m_strOut = dlg.m_ofn.lpstrFile;
		DoDataExchange(FALSE);
	}

	return 0;
}

LRESULT CTPFactoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// TODO: Add your message handler code here and/or call default
	DoDataExchange(FALSE);

	return TRUE;
}

LRESULT CTPFactoryView::OnBnClickedConvert(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here
	if ( 0 < m_strOut.GetLength()
		 && 0 < m_strConfig.GetLength()
		 && 0 < m_strMP3.GetLength() )
	{
		TPTools::CryptFile(m_strMP3, m_strConfig, m_strOut);
	}

	return 0;
}
